package eo.test.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

import org.hibernate.annotations.CollectionOfElements;

/**
 * 
 * @author takeshi
 * 
 */
@Entity
@NamedQuery(name = "oneNamedQuery", query = "from FieldEntity")
public class FieldEntity {
    @Id
    @GeneratedValue
    private long id;

    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
    private List<FieldEntity> children = new ArrayList<FieldEntity>();

    @ManyToOne
    private FieldEntity parent;

    @CollectionOfElements
    private List<Integer> numbers = new ArrayList<Integer>();

    @Embedded
    private EmbeddableEntity embedded;

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @return the children
     */
    public List<FieldEntity> getChildren() {
        return children;
    }

    /**
     * @return the parent
     */
    public FieldEntity getParent() {
        return parent;
    }

    /**
     * @return the numbers
     */
    public List<Integer> getNumbers() {
        return numbers;
    }

    /**
     * @return the embedded
     */
    public EmbeddableEntity getEmbedded() {
        return embedded;
    }

}
